<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
 <%@ page import="com.fit.user.dao.*"  %>
 <%@ page import="com.fit.user.entity.*"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%
String contextPath = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+contextPath+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
     <script language="JavaScript" src="dateselect.js"  charset="utf-8"></script>
    <title>My JSP 'manager.jsp' starting page</title>
   	<link href="<%=contextPath%>/img/skin/skin.css" rel="stylesheet" type="text/css" />
		<link href="<%=contextPath%>/css/sic.css" rel="stylesheet" type="text/css" />
	<style type="text/css">

body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #EEF2FB;
}


</style>

<script type="text/javascript">
function checkok()
{
		if(document.getElementById("bmbhid").value=="0")
		{
		alert("请选择部门编号!");
		return false;
		}
		else
		{
		return true;
		}
}
</script>
    </head>
    <%
    String flag =(String)request.getAttribute("flag");
    if(flag!=null){
    if(flag.equals("true"))
    {
    %>

    <script type="text/javascript">
				alert("添加用户成功!");
			</script>
    <%
    }else{
     %>
      
         <script type="text/javascript">
				alert("添加用户成失败!");
			</script>
     <%} 
       }%>

  <!-- 得到所有的部门信息 -->
  <%
  SectionMsgDAO sectionMsgDAO = new SectionMsgDAO();
  List<SectionMsgEntity> list = sectionMsgDAO.getSectionMsg();
   %>
  <body>



<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" valign="top" background="<%=contextPath%>/img/skin/mail_leftbg.gif"><img src="<%=contextPath%>/img/skin/left-top-right.gif" width="17" height="29" /></td>
    <td valign="top" background="<%=contextPath%>/img/skin/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">用户管理</div></td>
<a href="police/callback.jsp">回收站</a>
      </tr>
    </table></td>
    <td width="16" valign="top" background="<%=contextPath%>/img/skin/mail_rightbg.gif"><img src="<%=contextPath%>/img/skin/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td valign="middle" background="<%=contextPath%>/img/skin/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"  class="table_boder">
   
   <table width="100%" height="450" border="0" cellpadding="0" cellspacing="0" >
		<tr><td align="center"><h2>增加用户</h2></td></tr>
	<tr><td valign="top" align="center">
      
    <form action="<%=basePath %>/policeMsg.do?oper=submitPoliceMsg" method="post" enctype="multipart/form-data" onsubmit="return checkok()">
   <table class="table_boder">
    <tr>
    <td align="right">警号：</td><td><input type="text"  name="policeMsgEntity.policeID" /></td>
    <td align="right">姓名：</td><td><input type="text" style='width:200px' name="policeMsgEntity.policeName" /></td>
    </tr>
        <tr>
    <td align="right">性别：</td><td><input type="radio"  name="policeMsgEntity.policeSex" value="男" checked="checked" />男
                     <input type="radio"  name="policeMsgEntity.policeSex" value="女" />女
    </td>
    <td align="right">生日：</td><td><input type="text"  style='width:200px' readonly="readonly" name="policeMsgEntity.policeBith" onfocus="HS_setDate(this)" /></td>
    </tr>
        <tr>
    <td align="right">部门编号：</td>
    <td>
    <select id="bmbhid"  name="policeMsgEntity.policeSect" style='width:150px'>
     <option value="0">-请选择-</option>
		<c:forEach var="sectionMsgEntity" items="<%=list%>">
    <option value="${sectionMsgEntity.sectionID }">${sectionMsgEntity.sectionName }</option>
		</c:forEach>
    </select>
    </td>
    
    <td align="right">权限：</td><td>
    <select name="policeMsgEntity.purview" style='width:200px'>
    <option value="0">高级管理员</option>
    <option value="1">管理员</option>
    <option value="2">部门领导</option>
    <option value="3" selected="selected">办案民警</option>
    </select>
    </td>
    </tr>
        <tr>
    <td align="right">密码：</td><td><input type="text"  name="policeMsgEntity.policepw" /></td>
    </tr>
     <tr>
    <td align="right">相片：</td><td colspan="4"><input type="file" name="file"/><br/></td>
    </tr>
   <tr>
      <td colspan="2" align="center"><input type="submit" value="提交"> </td><td colspan="2"  align="center"><input type="button" name="cancel" value="重置"></td>
      
      </tr>
      </table>
    </form>
       <%
    String flag_del =(String)request.getParameter("flag_del");
    if(flag_del!=null){
    if(flag_del.equals("true"))
    {
    %>
   
     <script type="text/javascript">
				alert("删除用户成功!");
			</script>
    <%
    }else{
     %>
 
             <script type="text/javascript">
				alert("删除用户成失败!");
			</script>
     <%} 
       }%>

  
    <center><h2>查询用户</h2></center>
       <form action="<%=basePath %>/policeMsg.do?oper=getAllPoliceMsg" method="post">
   <table  class="table_boder">
    <tr>
    <td  align="center">警号：</td><td><input type="text" style='width:150px' name="policeMsgEntity.policeID" /></td>
    <td align="right">姓名：</td><td><input type="text" style='width:150px' name="policeMsgEntity.policeName" /></td>
    <td align="right">性别：</td><td><input type="radio" style='width:60px' name="policeMsgEntity.policeSex" value="男" checked="checked" />男
                     <input type="radio" style='width:60px' name="policeMsgEntity.policeSex" value="女" />女
    </td>
    </tr>
        <tr>
    
    <td align="right">生日：</td><td><input type="text"  style='width:150px' readonly="readonly" name="policeMsgEntity.policeBith" onfocus="HS_setDate(this)" /></td>
    <td align="right">部门编号：</td>
    <td>
    <select   name="policeMsgEntity.policeSect" style='width:150px'>
    	<option value="">-请选择-</option>
     	<c:forEach var="sectionMsgEntity" items="<%=list%>">
    				<option value="${sectionMsgEntity.sectionID }">${sectionMsgEntity.sectionName }</option>
		</c:forEach>
    </select>
    </td>
    <td align="right">权限：</td><td>
    <select name="policeMsgEntity.purview" style='width:150px'>
    <option value="">请选择管理权限</option>
    <option value="0">高级管理员</option>
    <option value="1">管理员</option>
    <option value="2">部门领导</option>
    <option value="3">办案民警</option>
    </select>
    </td>
    </tr>
       <tr>
      <td colspan="6" align="center">
      <input type="submit" value="提交"> 
      &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;
     <input type="button" name="cancel" value="重置"></td>
      
      </tr>
            </table>
    </form>
           <%
      
      List<PoliceMsgEntity> policeMsgEntities = (List<PoliceMsgEntity>)request.getAttribute("policeMsgEntities");
      request.setAttribute("policeMsgEntities",policeMsgEntities);
      if(policeMsgEntities != null){
      String[] table={"警号","姓名","性别","生日","部门编码","权限","密码","是否冻结","操作"};
      %>
      <table class="table_boder" cellSpacing="0" cellPadding="0" width="700">
        <tr  align="center" class="myrow" bgcolor="#1D639F">
  <c:forEach var="name" items="<%=table %>">
			 <td class="td_boder"  style="color:#ffffff;">${name }</td> 
  </c:forEach>
  </tr>
   <c:forEach var="policeMsgEntity" items = "<%=policeMsgEntities %>">
	<tr>
	<td>${policeMsgEntity.policeID }</td>
	<td>${policeMsgEntity.policeName }</td>
	<td>${policeMsgEntity.policeSex }</td>
	<td>${policeMsgEntity.policeBith }</td>
	<td>${policeMsgEntity.policeSect }</td>
	<td>${policeMsgEntity.purview }</td>
	<td>${policeMsgEntity.policepw }</td>
	<td>${policeMsgEntity.freeze }</td>
	 
	
	<td><a href ="<%=basePath %>/servlet/DeleteUser?policeID=${policeMsgEntity.policeID }">删除此用户</a>
	&nbsp;&nbsp;&nbsp;<a href ="<%=basePath %>police/manager_user_modify.jsp?policeID=${policeMsgEntity.policeID }">编辑此用户</a>
	&nbsp;&nbsp;&nbsp;<a href ="<%=basePath %>/servlet/FreezeUser?policeID=${policeMsgEntity.policeID }">冻结此用户</a>
	&nbsp;&nbsp;&nbsp;<a href ="<%=basePath %>/servlet/UnFreezeUser?policeID=${policeMsgEntity.policeID }">解冻此用户</a></td>
	</tr>
	</c:forEach>
	</table>
      <%
      }
       %>
   
   
   
						</td></tr></table>
	</td>
    <td background="<%=contextPath%>/img/skin/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="bottom" background="<%=contextPath%>/img/skin/mail_leftbg.gif"><img src="<%=contextPath%>/img/skin/buttom_left2.gif" width="17" height="17" /></td>
    <td background="<%=contextPath%>/img/skin/buttom_bgs.gif"><img src="<%=contextPath%>/img/skin/buttom_bgs.gif" width="17" height="17"></td>
    <td valign="bottom" background="<%=contextPath%>/img/skin/mail_rightbg.gif"><img src="<%=contextPath%>/img/skin/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>
  </body>
</html>
